package LeetcodeTest_thirty_nine;
//LCP 17.速算机器人

public class calculate
{
    public static void main(String[] args)
    {
        System.out.println(Solution.calculate("AB"));
    }
}
class Solution
{
    public static int calculate(String s)
    {
        int x=1;
        int y=0;
        for(int i=0;i<s.length();i++)
        {
            if(s.charAt(i)=='A')
            {
               x=2*x+y;
            }
            else
                y=2*y+x;
        }
        return x+y;
    }
}